﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

<%@ include file="/WEB-INF/include/meta.jsp"%>
<%@ include file="/WEB-INF/include/css.jsp"%>

</head>

<body>

  <%@ include file="/WEB-INF/include/header.jsp"%>

  <%@ include file="/WEB-INF/include/menu.jsp"%>

  <div class="container main-content report">

    <div class="panel panel-default x-panel x-panel-layout">

      <div class="panel-heading">
        <ol class="breadcrumb">
          <li><a href="${ctx.host}/report">报表</a></li>
          <li class="active">营收报表</li>
        </ol>
      </div>

      <div class="panel-body">

        <div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
          <%@ include file="/WEB-INF/include/submenu.jsp"%>
        </div>

        <div class="col-xs-10 x-panel-layout-right">

          <div class="x-breadcrumb-wrapper">

            <div class="x-breadcrumb clearfix">
              <h2>
                <i class="glyphicon glyphicon-fire"></i>&nbsp;&nbsp;<span>报表&nbsp;-&nbsp;营收报表</span>
              </h2>
              <div class="pull-right">
                <c:choose>
                  <c:when test="${not empty currentPrincipal.site}">
                    <span class="current-branchCode">${currentPrincipal.site.name}</span>
                  </c:when>
                  <c:otherwise>
                    <select name="site">
                      <option value="">所有门店</option>
                      <c:forEach var="site" items="${persist.getSites(currentPrincipal.id)}">
                        <option value="${site.id}" ${site.id == selectSite.id ? 'selected' : ''}>${site.name}</option>
                      </c:forEach>
                    </select>
                  </c:otherwise>
                </c:choose>
              </div>
            </div>

          </div>

          <div class="x-breadcrumb-wrapper top-margin-20" style="position: relative;">
            <fmt:formatDate value="${currentDate}" pattern="yyyy-MM-dd" var="day" />
            <ul class="nav nav-pills x-breadcrumb-nav">
              <li class="pull-left ${period eq 'day' ? 'active' : ''}"><a href="${ctx.host}/revenue-reports?site=${selectSite.id}&date=${day}&period=day">日</a></li>
              <li class="pull-left ${period eq 'week' ? 'active' : ''}"><a href="${ctx.host}/revenue-reports?site=${selectSite.id}&date=${day}&period=week">周</a></li>
              <li class="pull-left ${period eq 'month' ? 'active' : ''}"><a href="${ctx.host}/revenue-reports?site=${selectSite.id}&date=${day}&period=month">月</a></li>
              <div class="pull-right" style="margin-left: 15px;">
                <input type="text" class="form-control date" name="date" value="${day}" data-validate="required" placeholder="请选择日期" readOnly />
              </div>
              <a href="${ctx.host}/revenue-reports/export-view" data-target="#report-export" data-toggle="modal" class="btn btn-default x-btn btn-shadow btn-shadow-default pull-right">导出</a>
            </ul>
          </div>

          <div class="tab-content">
            <div class="tab-pane fade active in" style="min-height: 100px;">

              <h2 class="title">
                <i class="glyphicon glyphicon-triangle-right" style="color: #FF8100;" title=""></i>&nbsp;&nbsp;<span>关键指标</span>
                <c:choose>
                  <c:when test="${period == 'day'}">
                    <p class="form-control-statis pull-right">日期：${day}</p>
                  </c:when>
                  <c:otherwise>
                    <p class="form-control-statis pull-right">日期：${startDate}&nbsp;&nbsp;-&nbsp;&nbsp;${endDate}</p>
                  </c:otherwise>
                </c:choose>
              </h2>

              <div style="margin: 0 15px;">
                <div class="x-breadcrumb-content row key-data">
                  <div class="col-xs-3">
                    <h1>${statistics["purchaseTotal"]/100}</h1>
                    <p>营业额</p>
                  </div>
                  <div class="col-xs-3">
                    <h1>${statistics["purchaseAmount"]}</h1>
                    <p>总购买数</p>
                  </div>
                  <div class="col-xs-3">
                    <h1>${statistics["refundAmount"]}</h1>
                    <p>总退课数</p>
                  </div>
                  <div class="col-xs-3">
                    <h1>${statistics["refundTotal"]/100}</h1>
                    <p>总退课金额</p>
                  </div>
                </div>
              </div>

              <c:forEach var="currentSite" items="${empty selectSite ? (persist.getSites(currentPrincipal.id)) : selectSite.arraySite}">
                <h2 class="title">
                  <i class="glyphicon glyphicon-triangle-right" style="color: #FF8100;" title=""></i>&nbsp;&nbsp;<span>${currentSite.name}</span>
                </h2>

                <div style="margin: 0 15px;">
                  <table class="table table-striped table-hover x-table" style="margin-bottom: 20px;">
                    <thead>
                      <tr>
                        <th style="border-left: 1px solid #ccc; border-right: 1px solid #ccc;">大类</th>
                        <th colspan="4" style="border-right: 1px solid #ccc;">常规课</th>
                        <th colspan="6" style="border-right: 1px solid #ccc;">特色课</th>
                        <th colspan="2" style="border-right: 1px solid #ccc;">专项课</th>
                        <th colspan="6" style="border-right: 1px solid #ccc;">周期课</th>
                      </tr>
                    </thead>
                    <thead>
                      <tr>
                        <th style="border-left: 1px solid #ccc; border-right: 1px solid #ccc;">二类</th>
                        <th>常规课(其他)</th>
                        <th>青少年专项</th>
                        <th>急速燃脂</th>
                        <th  style="border-right: 1px solid #ccc;">基础塑形</th>
                        <th>燃脂拳击</th>
                        <th>悬挂训练</th>
                        <th>恢复再生</th>
                        <th>孕产恢复</th>
                        <th>普拉提</th>
                        <th  style="border-right: 1px solid #ccc;">形体雕刻</th>
                        <th>矫正美化</th>
                        <th  style="border-right: 1px solid #ccc;">运康损伤疼痛</th>
                        <th>年</th>
                        <th>月</th>
                        <th>季</th>
                        <th>特年</th>
                        <th>特月</th>
                        <th  style="border-right: 1px solid #ccc;">特季</th>
                      </tr>
                    </thead>
                    <tbody>
                      <tr>
                        <td style="border-left: 1px solid #ccc; border-right: 1px solid #ccc;">购买金额</td>
                        <td><fmt:formatNumber value="${reports['purchase']['1'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['2'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['37'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td  style="border-right: 1px solid #ccc;"><fmt:formatNumber value="${reports['purchase']['3'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['4'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['31'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['5'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['6'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['35'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td  style="border-right: 1px solid #ccc;"><fmt:formatNumber value="${reports['purchase']['7'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['8'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td  style="border-right: 1px solid #ccc;"><fmt:formatNumber value="${reports['purchase']['9'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['10'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['11'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['12'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['13'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['14'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td  style="border-right: 1px solid #ccc;"><fmt:formatNumber value="${reports['purchase']['15'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                      </tr>
                      <tr>
                        <td style="border-left: 1px solid #ccc; border-right: 1px solid #ccc;">购买数量</td>
                        <td><fmt:formatNumber value="${reports['purchase']['16'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['17'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['38'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td  style="border-right: 1px solid #ccc;"><fmt:formatNumber value="${reports['purchase']['18'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['19'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['30'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['20'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['21'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['36'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td style="border-right: 1px solid #ccc;"><fmt:formatNumber value="${reports['purchase']['22'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['23'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td  style="border-right: 1px solid #ccc;"><fmt:formatNumber value="${reports['purchase']['24'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['25'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['26'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['27'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['28'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['purchase']['29'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td  style="border-right: 1px solid #ccc;"><fmt:formatNumber value="${reports['purchase']['30'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        
                      </tr>
                      <tr>
                        <td  style="border-left: 1px solid #ccc; border-right: 1px solid #ccc;">退款金额</td>
                        <td><fmt:formatNumber value="${reports['refund']['1'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['2'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['37'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td style="border-right: 1px solid #ccc;"><fmt:formatNumber value="${reports['refund']['3'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['4'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['31'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['5'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['6'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['35'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td style="border-right: 1px solid #ccc;"><fmt:formatNumber value="${reports['refund']['7'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['8'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td style="border-right: 1px solid #ccc;"><fmt:formatNumber value="${reports['refund']['9'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['10'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['11'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['12'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['13'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['14'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                        <td style="border-right: 1px solid #ccc;"><fmt:formatNumber value="${reports['refund']['15'][currentSite.transferId]/100}" pattern="0"></fmt:formatNumber></td>
                      </tr>
                      <tr>
                        <td style="border-left: 1px solid #ccc; border-right: 1px solid #ccc;">退款数量</td>
                        <td><fmt:formatNumber value="${reports['refund']['16'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['17'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['38'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td  style="border-right: 1px solid #ccc;"><fmt:formatNumber value="${reports['refund']['18'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['19'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['32'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['20'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['21'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['36'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td  style="border-right: 1px solid #ccc;"><fmt:formatNumber value="${reports['refund']['22'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['23'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td  style="border-right: 1px solid #ccc;"><fmt:formatNumber value="${reports['refund']['24'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['25'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['26'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['27'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['28'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td><fmt:formatNumber value="${reports['refund']['29'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                        <td  style="border-right: 1px solid #ccc;"><fmt:formatNumber value="${reports['refund']['30'][currentSite.transferId]/1}" pattern="0"></fmt:formatNumber></td>
                      </tr>
                    </tbody>
                  </table>
                </div>
              </c:forEach>

              <h2 class="title clearfix">
                <i class="glyphicon glyphicon-triangle-right" style="color: #FF8100;" title=""></i>&nbsp;&nbsp;<span>详细数据</span>
              </h2>

              <div id="grid-wrap" style="min-height: 490px;"></div>

            </div>
          </div>

        </div>

      </div>

    </div>

  </div>

  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource root="${ctx.resource}/build" type="script" src="js/page/report/revenue-report.js">
    <script type="text/javascript">
      require(['page/report/revenue-report'], function(page) {
        page.init({
          "date": '${day}',
          "site": '${selectSite.id}',
          "period": '${period}',
          "today": '${today}'
        })
      })
    </script>
  </d:resource>

</body>
</html>